package com.crt.uav.domain;

import java.io.Serializable;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
@Schema(description = "响应返回对象")
public class Result implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(title = "status", description = "响应状态码" )
    private int status;
    
    @Schema(title = "msg", description = "响应消息" )
    private String msg;

    @Schema(title = "data", description = "响应数据" )
    private Object data;

    public Result() {
        this.status = 200;
        this.msg = "success";
        this.data = null;
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.setStatus(200);
        result.setMsg("success");
        result.setData(data);
        return result;
    }

    public static Result success(Integer code, Object data) {
        Result result = new Result();
        result.setStatus(code);
        result.setMsg("success");
        result.setData(data);
        return result;
    }

    public static Result error(String message) {
        return error(500, message);
    }

    public static Result error(int code, String message) {
        Result result = new Result();
        result.setStatus(code);
        result.setMsg(message);
        return result;
    }

}
